//
//  AyUserTool.m
//  xWeibo
//
//  Created by alvis mac on 10/31/15.
//  Copyright © 2015 alvis. All rights reserved.
//

#import "AyUserTool.h"
#import "AyHttpTool.h"
#import "MJExtension.h"
#import "IWFriendshipParam.h"
#import "IWFriendshipResult.h"

@implementation AyUserTool

+ (void)userInfoWithParam:(AyUserInfoParam *)param success:(void (^)(AyUserInfoResult *))success failure:(void (^)(NSError *))failure
{
    [AyHttpTool getWithURL:@"https://api.weibo.com/2/users/show.json" params:param.keyValues success:^(id json) {
        if (success) {
            AyUserInfoResult *result = [AyUserInfoResult objectWithKeyValues:json];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)userUnreadCountWithParam:(AyUserUnreadCountParame *)param success:(void (^)(AyUserUnreadCountResult *result))success failure:(void (^)(NSError *error))failure
{
    [AyHttpTool getWithURL:@"https://api.weibo.com/2/remind/unread_count.json" params:param.keyValues success:^(id json) {
        if (success) {
            AyUserUnreadCountResult *result = [AyUserUnreadCountResult objectWithKeyValues:json];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)friendsWithParam:(IWFriendshipParam *)param success:(void (^)(IWFriendshipResult *result))success failure:(void (^)(NSError *error))failure{
    [AyHttpTool getWithURL:@"https://api.weibo.com/2/friendships/friends.json" params:param.keyValues success:^(id json) {
        if (success) {
            IWFriendshipResult *result = [IWFriendshipResult objectWithKeyValues:json];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

+ (void)followersWithParam:(IWFriendshipParam *)param success:(void (^)(IWFriendshipResult *result))success failure:(void (^)(NSError *error))failure{
    [AyHttpTool getWithURL:@"https://api.weibo.com/2/friendships/followers.json" params:param.keyValues success:^(id json) {
        if (success) {
            IWFriendshipResult *result = [IWFriendshipResult objectWithKeyValues:json];
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


@end
